package com.xincongjun.media.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static com.xincongjun.media.utils.DateTimeUtil.formatCompactDatetime;
import static com.xincongjun.media.utils.DateTimeUtil.formatTimestampMillis;

public class ParseDateTimeFromFilenameUtil {

    private static final Logger logger = LoggerFactory.getLogger(ParseDateTimeFromFilenameUtil.class);

//    日期时间
    /**
     * 解析文件名
     * 例如：IMG_20240125_224150.jpg
     */
    public static String parseFileNameToDateTime01(String fileName){
        String[] str = fileName.split("_");
        String dateTime = str[1] + str[2];
        return formatCompactDatetime(dateTime);
    }



//    时间戳
    /**
     * 解析文件名
     * 例如：Image_1710232555492.jpg
     */
    public static String parseFileNameToTimestamp01(String fileName){
        String[] str = fileName.split("_");
        String dateTime = str[1];
        return formatTimestampMillis(dateTime);
    }

}
